package smcms.service.order.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import smcms.commons.api.entity.result.CommonsResult;
import smcms.service.order.entity.*;
import smcms.service.order.service.BusinessDisplayService;

import java.util.List;

@RestController
@RequestMapping("/BusinessDisplayController")
public class BusinessDisplayController {
    @Autowired
    private BusinessDisplayService businessDisplayService;
    @Autowired
    private CommonsResult commonsResult;

    @PostMapping("/getWeekSales")
    public CommonsResult getWeekSales(@RequestBody WeekSaleReq req){
        List<WeekSaleResp> weekSales = businessDisplayService.getWeekSales(req);
        return commonsResult.success(weekSales);
    }

    @PostMapping("/getWeekInAndOut")
    public CommonsResult getWeekInAndOut(@RequestBody WeekSaleReq req){
        List<WeekSaleResp> weekSales = businessDisplayService.getWeekInAndOut(req);
        return commonsResult.success(weekSales);
    }

    @PostMapping("/getProductRange")
    public CommonsResult getProductRange(@RequestBody WeekSaleReq req){
        List<RangeResp> weekSales = businessDisplayService.getProductRange(req);
        return commonsResult.success(weekSales);
    }

    @PostMapping("/getSalePercent")
    public CommonsResult getSalePercent(@RequestBody WeekSaleReq req){
        List<SalePercent> salePercent = businessDisplayService.getSalePercent(req);
        return commonsResult.success(salePercent);
    }

    @PostMapping("/getStatistics")
    public CommonsResult getStatistics(@RequestBody WeekSaleReq req){
        Statistics statistics = businessDisplayService.getStatistics(req);
        return commonsResult.success(statistics);
    }

    @PostMapping("/getInventory")
    public CommonsResult getInventory(@RequestBody WeekSaleReq req){
        List<InventoryResp> inventory = businessDisplayService.getInventory(req);
        return commonsResult.success(inventory);
    }

    @PostMapping("/getRatio")
    public CommonsResult getRatio(@RequestBody WeekSaleReq req){
        List<RatioResp> ratioRespList = businessDisplayService.getRatio(req);
        return commonsResult.success(ratioRespList);
    }

}
